package com.genius.app.controller;

import com.genius.util.ControllerHelper.Helper;
import com.genius.app.bean.App;
import com.genius.util.Common.Result;
import com.genius.app.service.AppService;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/app")
public class AppController {

    @Autowired
    AppService appService;

    @GetMapping("/appList")
    public Result getAppList(HttpServletRequest request) throws JsonProcessingException {
        String username = Helper.getUserName(request);
        String uid = Helper.getUserId(request);
        System.out.println(username+"             "+uid);
        List<App> officeAppList = appService.getAppList(username);
        return Result.success( Map.of("officeAppList",officeAppList));
    }
}
